/*
 * FarmConfig.hpp
 *
 *  Created on: 2013-1-19
 *      Author: heqiu
 */

#ifndef FARMCONFIG_H_
#define FARMCONFIG_H_

#include "Guud.h"

using namespace std;
using namespace guud;

class FarmConfig: public GuudConfig {
public:
	int32_t getWindowX() {
		TiXmlHandle docHandle(&m_xml);
		TiXmlHandle handle =
				docHandle.FirstChildElement("root").FirstChildElement("window").FirstChildElement(
						"pos_x");
		return atoi(handle.Element()->GetText());
	}
	int32_t getWindowY() {
		TiXmlHandle docHandle(&m_xml);
		TiXmlHandle handle =
				docHandle.FirstChildElement("root").FirstChildElement("window").FirstChildElement(
						"pos_y");
		return atoi(handle.Element()->GetText());
	}
	int32_t getWindowSize() {
		TiXmlHandle docHandle(&m_xml);
		TiXmlHandle handle =
				docHandle.FirstChildElement("root").FirstChildElement("window").FirstChildElement(
						"size");
		return atoi(handle.Element()->GetText());
	}
	uint32_t getWindowWidth() {
		TiXmlHandle docHandle(&m_xml);
		TiXmlHandle handle =
				docHandle.FirstChildElement("root").FirstChildElement("window").FirstChildElement(
						"width");
		return strtoul(handle.Element()->GetText(), NULL, 10);
	}
	uint32_t getWindowHeight() {
		TiXmlHandle docHandle(&m_xml);
		TiXmlHandle handle =
				docHandle.FirstChildElement("root").FirstChildElement("window").FirstChildElement(
						"height");
		return strtoul(handle.Element()->GetText(), NULL, 10);
	}
	uint32_t getWindowBPP() {
		TiXmlHandle docHandle(&m_xml);
		TiXmlHandle handle =
				docHandle.FirstChildElement("root").FirstChildElement("window").FirstChildElement(
						"bpp");
		return strtoul(handle.Element()->GetText(), NULL, 10);
	}
	string getWindowCaption() {
		TiXmlHandle docHandle(&m_xml);
		TiXmlHandle handle =
				docHandle.FirstChildElement("root").FirstChildElement("window").FirstChildElement(
						"caption");
		return handle.Element()->GetText();
	}
	uint32_t getCurMap() {
		TiXmlHandle docHandle(&m_xml);
		TiXmlHandle handle =
				docHandle.FirstChildElement("root").FirstChildElement("map").FirstChildElement(
						"cur_no");
		return strtoul(handle.Element()->GetText(), NULL, 10);
	}
	uint32_t getMapShort() {
		TiXmlHandle docHandle(&m_xml);
		TiXmlHandle handle =
				docHandle.FirstChildElement("root").FirstChildElement("map").FirstChildElement(
						"short");
		return strtoul(handle.Element()->GetText(), NULL, 10);
	}
	uint32_t getMapLong() {
		TiXmlHandle docHandle(&m_xml);
		TiXmlHandle handle =
				docHandle.FirstChildElement("root").FirstChildElement("map").FirstChildElement(
						"long");
		return strtoul(handle.Element()->GetText(), NULL, 10);
	}

	void getBuildings();
	void getBuildingType();
	void getFarmControl();

};

#endif /* FARMCONFIG_H_ */
